package com.base.cn.platform.os.controller.statistics;

import com.base.cn.platform.os.common.AdminBaseController;
import com.base.cn.platform.os.service.manage.statistics.users.UsersStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;


/**
 * 考试数据统计Controller
 *
 * @author s.li
 * @create 2018-08-24-16:50
 */
@Controller
@RequestMapping("/admin/stat")
public class UsersStatController extends AdminBaseController {

    @Autowired
    private UsersStatisticsService usersStatisticsService;


    @RequestMapping("/users")
    public String users(){
        return resultPage("/statistics/users/users-statistics");
    }

    /**
     * 用户趋势看板数据
     * @param type
     * @param startTime
     * @param endTime
     * @return Map<String,Object>
     */
    @RequestMapping("/queryUserTrendBoard")
    @ResponseBody
    public Map<String,Object> queryUserTrendBoard(@RequestParam(value = "type",required = false,defaultValue = "1") int type,
                                                  @RequestParam(value = "startTime",required = false) Date startTime,
                                                  @RequestParam(value = "endTime",required = false) Date endTime){
        Map<String,Object> params =new HashMap<>();
        params.put("type",type);
        params.put("startTime",startTime);
        params.put("endTime",endTime);
        return usersStatisticsService.queryUserTrendBoard(params);
    }

    /**
     * 查询付款用户概况数据
     * @return Map<String,Object>
     */
    @RequestMapping("/queryPayUserCountData")
    @ResponseBody
    public Map<String,Object> queryPayUserCountData(@RequestParam("date") String date){
        return usersStatisticsService.queryPayUserCountData(date);
    }

    /**
     * 用户注册渠道概况
     * @return Map<String,Object>
     */
    @RequestMapping("/queryUserRegFormCountData")
    @ResponseBody
    public Map<String,Object> queryUserRegFormCountData(){
        return usersStatisticsService.queryUserRegFormCountData();
    }
}
